<!DOCTYPE html>
<html>
<?php 
	include "db_function.php";
	session_start();
	$uid = intval($_SESSION['uid']);
	if($uid < 1){
		header("location: login.php");
		die;
	}
?>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link media="all" href="./css/one-debug.css" rel="stylesheet">
	<link media="all" href="css/main.css" type="text/css" rel="stylesheet"/>
	<script type=""text/javascript src="./js/jq/jquery-1.8.3.js"></script>
	<script type=""text/javascript src="./js/my.js"></script>
</head>
<body>
	<div class="wrapper">
		<div class="head-area">
			<h1>
				<a href="./index.php" class="head_area">GuoBa留言本</a>
			</h1>
			<span class="ctr-bar">
				欢迎: <?php echo $_SESSION['username']; ?>|<a href='logout.php'>退出</a>
			</span>
			<div class="clear"></div>
		</div>
	
		<div class="ui-nav ui-nav-nosub">
  			<ul class="ui-nav-main">
	   			<li class="ui-nav-item ui-nav-item-current">
	     			<a href="index.php">看帖</a>
    			</li>
    			<li class="ui-nav-item">
	     			<a href="showpost.php">发帖</a>
    			</li>
    		</ul>
    	</div>
	<?php
		$post_list = get_post_list();
	?>
		<div class="content-area">
			<div class="ui-table-container">
		        <table class="ui-table"><!-- 可以在class中加入ui-table-inbox或ui-table-noborder分别适应不同的情况 -->
		            <thead>
		                <tr>
		                    <th>帖子ID</th>
		                    <th>主题</th>
		                    <th>发布者</th>
		                </tr>
		            </thead>
		            <tbody>
		                <?php foreach ($post_list as $p_num => $p_arr):
		                    $username = get_username($p_arr['uid']);
		                ?>
		                <tr class="ui-table-split">
		                    <td><?=$p_arr['id']?></td>
		                    <td><a href='post.php?pid=<?=$p_arr['id']?>'><?=$p_arr['title']?></a></td>
		                    <td><?=$username?></td>
		                </tr>         
		            <?php endforeach;?>
		            </tbody>
		            <tfoot>
		            </tfoot><!-- 表尾可选 -->
		        </table>
	    	</div>
		</div>
	</div>
</body>
</html>